package com.itheima.controller;


import com.itheima.pojo.Result;
import com.itheima.pojo.User;
import com.itheima.queryParams.LoginInfoParam;
import com.itheima.service.LoginServise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginServise loginServise;

    @PostMapping
    public Result userLogin(@RequestBody User user){
        LoginInfoParam loginInfoParam = loginServise.userLogin(user);
        if (loginInfoParam != null){
            return Result.success(loginInfoParam);
        }
        return Result.error("登入账号或者密码错误！刘岩是大畜生！");
    }
}
